package com.my.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.my.entity.Menu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenuMapper extends BaseMapper<Menu> {

    List<Menu> getMenu(@Param("userId") Long userId, @Param("type") Integer type);

    @Select("select m.id, m.parent_id, m.name, m.deep, m.sort, (um.id is not null) as checked from menu m left join user_menu um on m.id = um.menu_id and um.user_id = #{userId} and um.type = #{type} where m.id != 11 and m.parent_id != 11")
    List<Menu> getUserMenu(@Param("userId") Long userId, @Param("type") Integer type);

}
